package pw.yumc.Residence.commandsub;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import cn.citycraft.PluginHelper.commands.BaseCommand;
import pw.yumc.Residence.ResidenceMain;
import pw.yumc.Residence.text.Language;

public class CommandMaterial extends BaseCommand {
    ResidenceMain plugin;

    public CommandMaterial(final ResidenceMain plugin) {
        super();
        this.plugin = plugin;
        setMinimumArguments(1);
        setOnlyPlayerExecutable();
    }

    @SuppressWarnings("deprecation")
    @Override
    public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
        final Player player = (Player) sender;

        final Language language = plugin.getLanguage();

        try {
            player.sendMessage(ChatColor.GREEN
                    + language.getPhrase("MaterialGet", ChatColor.GOLD + args[0] + ChatColor.GREEN + "." + ChatColor.RED + Material.getMaterial(Integer.parseInt(args[0])).name() + ChatColor.GREEN));
        } catch (final Exception ex) {
            player.sendMessage(ChatColor.RED + language.getPhrase("InvalidMaterial"));
        }
    }

}
